package com.www.applyword.ui.chat;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.tencent.qcloud.tim.uikit.modules.chat.base.ChatInfo;
import com.www.applyword.Constants.Constants;
import com.www.applyword.R;
import com.www.applyword.base.BaseActivity;
import com.www.applyword.fragment.ChatFragment2;
import com.www.applyword.main.LoginActivity;

/**
 * author : huang
 * date   : 2019/11/16 0016 11:08
 * version: 1.0
 */
public class ChatActivity extends BaseActivity {
    private ChatFragment2 mChatFragment;
    private ChatInfo mChatInfo;

    @Override
    protected void loadViewLayout() {
        setContentView(R.layout.chat_activity);
        setHead_title(View.GONE);
    }

    @Override
    protected void loadData() {
        Bundle bundle = getIntent().getExtras();
        if (bundle == null) {
            startSplashActivity();
        } else {
            mChatInfo = (ChatInfo) bundle.getSerializable(Constants.CHAT_INFO);
            if (mChatInfo == null) {
                startSplashActivity();
                return;
            }
            mChatFragment = new ChatFragment2();
            mChatFragment.setArguments(bundle);
            getSupportFragmentManager().beginTransaction().replace(R.id.empty_view, mChatFragment).commitAllowingStateLoss();

        }
    }

    private void startSplashActivity() {
        Intent intent = new Intent(ChatActivity.this, LoginActivity.class);
        startActivity(intent);
        finish();
    }
}
